﻿using System.Globalization;
using System.Windows.Data;
using System.Windows.Media;

namespace jq9602_jq9603.View
{
    internal class ResultConverter : IValueConverter
    {
        public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
        {
            bool? result = value as bool?;
            if (parameter?.ToString() == "color")
            {
                if (result == true)
                {
                    return Brushes.Green;
                }
                else if (result == false)
                {
                    return Brushes.OrangeRed;
                }
                else
                {
                    return Brushes.Transparent;
                }
            }
            else
            {
                if (result == true)
                {
                    return "OK";
                }
                else if (result == false)
                {
                    return "NG";
                }
                else
                {
                    return "WAITING";
                }
            }
        }

        public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}